ABC135 C - City Savers
https://atcoder.jp/contests/abc135/tasks/abc135_c
提出
code: python
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
tmp = ai - bi
# i番目を戦士iが全部倒せた
if (tmp < 0):
ans += ai
ai = 0
tmp2 = ai+1 - abs(tmp)
# i+1番目を戦士iの余力で全部倒せた
if (tmp2 < 0):
ans += ai+1
ai+1 = 0
else:
ans += abs(tmp)
ai+1 -= abs(tmp)
else:
ans += bi
ai = tmp
print(ans)